package org.zfes.snowier.zbss.xzy.router.others;

import java.util.List;
import java.util.Map;
import java.util.Optional;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.zfes.snowier.core.data.DataSet;
import org.zfes.snowier.web.controller.BaseController;
import org.zfes.snowier.zbss.xzy.biz.config.model.ConfigItem;
import org.zfes.snowier.zbss.xzy.biz.config.service.IConfigItemService;
@Controller 
@RequestMapping("/xzy/aIConfigItem")
public class AIConfigItemController implements BaseController {

	
	@Autowired
	private IConfigItemService aIConfigItemService;
	
    @RequestMapping(value="/loadAIConfigItemDataSet", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
    public @ResponseBody  Object loadAIConfigItemDataSet(@RequestParam Map<String,Object> params){
	    DataSet dataSet=  aIConfigItemService.loadAIConfigItemDataSet(params);
	    return ajaxQuery("dataSet", dataSet);
    }
    
    @RequestMapping(value="/loadItemByCate", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
    public @ResponseBody  Object loadItemByCate(Long cateId,Byte status){
    	List<ConfigItem> itemList =aIConfigItemService.loadItemByCate(cateId,status);
	    return ajaxQuery("itemList", itemList);
    }
	
    @RequestMapping(value="/createAIConfigItem", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
    public  @ResponseBody Object createAIConfigItem(ConfigItem aIConfigItem){
		aIConfigItemService.createAIConfigItem(aIConfigItem);
    	return ajaxDoneSuccess("数据操作成功 ");
    }
	
    @RequestMapping(value="/loadAIConfigItem", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
    public @ResponseBody  Object loadAIConfigItem(Long id){
		Optional<ConfigItem> ops = aIConfigItemService.loadAIConfigItemById(id);
		return ajaxQuery("aIConfigItem",ops);
    }
	
    @RequestMapping(value="/updateAIConfigItem", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
    public @ResponseBody  Object updateAIConfigItem(ConfigItem aIConfigItem){
		aIConfigItemService.updateAIConfigItem(aIConfigItem);
		return ajaxDoneSuccess("数据操作成功 ");
    }
	
    @RequestMapping(value="/deleteAIConfigItem", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
    public @ResponseBody  Object deleteAIConfigItem(Long id){
		aIConfigItemService.deleteAIConfigItem(id);
		return ajaxDoneSuccess("数据操作成功 ");
    }

    
    @RequestMapping(value="/setAIConfigItemStatus", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
    public @ResponseBody  Object setAIConfigItemStatus(Long id,Byte status){
    	aIConfigItemService.setAIConfigItemStatus(id, status);
		return ajaxDoneSuccess("数据操作成功 ");
    }
    
}